package com.yixing.tech.wcs.tcp;

import com.yixing.tech.wcs.constant.DictId;

import java.io.Serializable;

public enum InteractionState implements Serializable {
    PREPARED("准备放下", "prepared", DictId.BoxInteractState.PREPARED),
    PUT_DOWN_FINISHED("放下料箱", "putDownFinished", DictId.BoxInteractState.PUT_DOWN_FINISHED),
    PUT_DOWN_NOTIFIED("放下料箱通知", "putDownNotified", DictId.BoxInteractState.PUT_DOWN_NOTIFIED),
    HANDLING_FINISHED("完成处理", "handlingFinished", DictId.BoxInteractState.HANDLING_FINISHED),
    HANDLING_NOTIFIED("完成处理通知", "handlingNotified", DictId.BoxInteractState.HANDLING_NOTIFIED),

    PREPARED_TAKE_OUT("准备取出", "preparedTakeOut", DictId.BoxInteractState.PREPARED_TAKE_OUT),
    PICK_UP_FINISHED("完成取出", "pickUpFinished", DictId.BoxInteractState.PICK_UP_FINISHED),
    PICK_UP_NOTIFIED("完成取出通知", "pickUpNotified", DictId.BoxInteractState.PICK_UP_NOTIFIED);

    private final String name;
    private final String code;
    private final String dictId;

    InteractionState(String name, String code, String dictId) {
        this.name = name;
        this.code = code;
        this.dictId = dictId;
    }

    public String getName() {
        return name;
    }

    public String getCode() {
        return code;
    }

    public String getDictId() {
        return dictId;
    }

    public static InteractionState getByName(String name) {
        for(InteractionState state: values()) {
            if(state.name.equals(name))
                return state;
        }
        return null;
    }

    public static InteractionState getByCode(String code) {
        for(InteractionState state: values()) {
            if(state.code.equals(code))
                return state;
        }
        return null;
    }

    public static InteractionState getByDictId(String dictId) {
        for(InteractionState state: values()) {
            if(state.dictId.equals(dictId))
                return state;
        }
        return null;
    }

    @Override
    public String toString() {
        return "InteractionState{" +
                "name='" + name + '\'' +
                ", code='" + code + '\'' +
                ", dictId='" + dictId + '\'' +
                '}';
    }
}
